package edu.chalmers.gos;

import java.util.ArrayList;
import java.util.HashMap;

public class Cards{
	private static Cards instance;
	public static HashMap<String, Card> cards = new HashMap<String, Card>();
	public ArrayList<Card> darkDeck = new ArrayList<Card>();
	
	private Cards(){
		addCard(-1, Card.NONE, Card.NONE, 0, false, false, false, 0, 0, 0);
		addCard(-1, Card.RESOURCES, Card.RESOURCES, 0, false, false, false, 0, 0, 0);
		
		addCard(0, Card.DARK_OMEN, Card.PLOT, 0, false, false, false, 0, 2, 2);
		addCard(0, Card.SEASON_OF_THE_REAPER, Card.PLOT, 0, false, false, false, 0, 3, 1);
		addCard(0, Card.RAINBOW_ROAD, Card.PLOT, 0, false, false, false, 0, 1, 3);
		addCard(1, Card.GOBLIN_DEATH_SQUAD, Card.UNIT, 1, true, true, true, 1, 0, 0);
		addCard(2, Card.GOBLIN_ALCHEMIST, Card.UNIT, 2, false, true, true, 2, 0, 0);
		addCard(3, Card.OGRE_MARAUDER, Card.UNIT, 3, true, false, false, 4, 0, 0);
		addCard(4, Card.FOUL_KNIGHT, Card.UNIT, 2, true, true, true, 2, 0, 0);
		addCard(5, Card.THE_FLESH_MAGE, Card.UNIT, 3, false, true, true, 3, 0, 0);
		addCard(6, Card.ROTTEN_SWAMP, Card.LAND, 0, false, false, false, 0, 1, 0);
		addCard(7, Card.FLIMSY_KITCHEN_KNIFE, Card.EQUIP, 1, true, false, false, 1, 0, 0);
		addCard(8, Card.SUDDEN_ILLNESS, Card.EVENT, 0, false, false, false, 0, 0, 0);
		
		darkDeck.add(cards.get(Card.DARK_OMEN));
		darkDeck.add(cards.get(Card.SEASON_OF_THE_REAPER));
		darkDeck.add(cards.get(Card.RAINBOW_ROAD));
		darkDeck.add(cards.get(Card.GOBLIN_DEATH_SQUAD));
		darkDeck.add(cards.get(Card.GOBLIN_DEATH_SQUAD));
		darkDeck.add(cards.get(Card.GOBLIN_DEATH_SQUAD));
		darkDeck.add(cards.get(Card.GOBLIN_DEATH_SQUAD));
		darkDeck.add(cards.get(Card.GOBLIN_ALCHEMIST));
		darkDeck.add(cards.get(Card.GOBLIN_ALCHEMIST));
		darkDeck.add(cards.get(Card.GOBLIN_ALCHEMIST));
		darkDeck.add(cards.get(Card.OGRE_MARAUDER));
		darkDeck.add(cards.get(Card.OGRE_MARAUDER));
		darkDeck.add(cards.get(Card.FOUL_KNIGHT));
		darkDeck.add(cards.get(Card.FOUL_KNIGHT));
		darkDeck.add(cards.get(Card.THE_FLESH_MAGE));
		darkDeck.add(cards.get(Card.ROTTEN_SWAMP));
		darkDeck.add(cards.get(Card.ROTTEN_SWAMP));
		darkDeck.add(cards.get(Card.ROTTEN_SWAMP));
		darkDeck.add(cards.get(Card.ROTTEN_SWAMP));
		darkDeck.add(cards.get(Card.ROTTEN_SWAMP));
		darkDeck.add(cards.get(Card.FLIMSY_KITCHEN_KNIFE));
		darkDeck.add(cards.get(Card.FLIMSY_KITCHEN_KNIFE));
		darkDeck.add(cards.get(Card.SUDDEN_ILLNESS));
		darkDeck.add(cards.get(Card.SUDDEN_ILLNESS));
		darkDeck.add(cards.get(Card.SUDDEN_ILLNESS));
	}
	
	private void addCard(int id, String name, String type, int cost, boolean red, boolean blue, boolean green, int power, int production, int initiative){
		cards.put(name, new Card(id, name, type, cost, red, blue, green, power, production, initiative));
	}
	
	public static Cards getInstance(){
		if(instance == null){
			instance = new Cards();
		}
		return instance;
	}

	public class Card{
		public int id;
		public String name;
		public String type;
		public int cost;
		public boolean red;
		public boolean green;
		public boolean blue;
		public int power;
		public int production;
		public int initiative;
		
		public final static String PLOT = "plot";
		public final static String LAND = "land";
		public final static String UNIT = "unit";
		public final static String EQUIP = "equipment";
		public final static String EVENT = "event";
		public final static String NONE = "none";
		public final static String RESOURCES = "resources";
		
		public final static String KNEEL = "kneel";
		public final static String RED = "red";
		public final static String GREEN = "green";
		public final static String BLUE = "blue";
		
		public final static String DARK_OMEN = "Dark Omen";
		public final static String SEASON_OF_THE_REAPER = "Season of the Reaper";
		public final static String RAINBOW_ROAD = "Rainbow Road";
		public final static String GOBLIN_DEATH_SQUAD = "Goblin Death Squad";
		public final static String GOBLIN_ALCHEMIST = "Goblin Alchemist";
		public final static String OGRE_MARAUDER = "Ogre Marauder";
		public final static String FOUL_KNIGHT = "Foul Knight";
		public final static String THE_FLESH_MAGE = "The Flesh Mage";
		public final static String ROTTEN_SWAMP = "Rotten Swamp";
		public final static String FLIMSY_KITCHEN_KNIFE = "Flimsy Kitchen Knife";
		public final static String SUDDEN_ILLNESS = "Sudden Illness";
		
		public Card(int id, String name, String type, int cost, boolean red, boolean blue, boolean green, int power, int production, int initiative){
			this.id = id;
			this.name = name;
			this.type = type;
			this.cost = cost;
			this.red = red;
			this.blue = blue;
			this.green = green;
			this.power = power;
			this.production = production;
			this.initiative = initiative;
		}
		
		public boolean hasType(String type){
			return this.type.equals(type);
		}
	}
}
